//
//  YWDailyReportDetailTVC.m
//  maintain
//
//  Created by 烟雨云渊 on 2017/6/6.
//  Copyright © 2017年 ewin. All rights reserved.
//

#import "YWDailyReportDetailTVC.h"
#import "YWCommonTool.h"
#import "NSDate+YYAdd.h"
#import "YWMacro.h"
#import "UIColor+CustomColors.h"

#import "YWDailyReport.h"
#import "YWDailyReportDetailCell.h"
#import "YWWorkReminderManager.h"
@interface YWDailyReportDetailTVC ()
//@property (nonatomic, strong) NSMutableArray * dataSource;
@property (nonatomic, strong) UIView * headView;
@property (nonatomic, strong) UIButton * buildingBtn;
@property (nonatomic, strong) UIButton * shareBtn;
@end

@implementation YWDailyReportDetailTVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"——工作日报";
    [self setupTableView];
}

- (void)setupTableView{
    self.view.backgroundColor = [UIColor customBackgroudColor];
    [self.tableView registerClass:[YWDailyReportDetailCell class] forCellReuseIdentifier:YWDailyReportDetailCellIdentifier];
    self.tableView.tableFooterView = [[UIView alloc] init];
    self.tableView.tableHeaderView = self.headView;
    self.tableView.sectionFooterHeight = 0.01;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    self.tableView.estimatedRowHeight = 44.0f;
    self.tableView.rowHeight = UITableViewAutomaticDimension;
}

- (void)setDailyReportArray:(NSMutableArray *)dailyReportArray{
    _dailyReportArray = dailyReportArray;
//    [_dataSource addObjectsFromArray:_dailyReportArray];
}

//- (NSMutableArray*)dataSource{
//    if (!_dataSource) {
//        _dataSource = [NSMutableArray array];
//    }
//    return _dataSource;
//}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return [self.dailyReportArray count];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}

- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    YWDailyReportDetailCell * cell = [tableView dequeueReusableCellWithIdentifier:YWDailyReportDetailCellIdentifier];
    cell.dailyReport = self.dailyReportArray[indexPath.section];
    return cell;
}

- (UIView *)headView{
    if (!_headView) {
        UIView * headView = [[UIView alloc] init];
        headView.frame = CGRectMake(0, 0, SCREEN_WIDTH, 50);
        headView.backgroundColor = [UIColor whiteColor];
        _headView = headView;
        self.buildingBtn.frame = CGRectMake((SCREEN_WIDTH/3), 6, SCREEN_WIDTH/3, kButtonH);
        self.shareBtn.frame = CGRectMake((SCREEN_WIDTH-33), 12, 23, 23);
        [_headView addSubview:self.buildingBtn];
        [_headView addSubview:self.shareBtn];
    }
    return _headView;
}

- (UIButton*)buildingBtn{
    if (!_buildingBtn) {
        UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
        [button setBackgroundColor:[UIColor whiteColor]];
        [button setTitle:@"楼盘" forState:UIControlStateNormal];
        [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        _buildingBtn = button;
        [_headView addSubview:_buildingBtn];
    }
    return _buildingBtn;
}

- (UIButton*)shareBtn{
    if (!_shareBtn) {
        UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
        [button setImage:[UIImage imageNamed:@"common_share"] forState:UIControlStateNormal];
        [button addTarget:self action:@selector(shareBtnTouchEvent:) forControlEvents:UIControlEventTouchUpInside];
        _shareBtn = button;
        [_headView addSubview:_shareBtn];
    }
    return _shareBtn;
}

- (void)shareBtnTouchEvent:(id)sender{
    
}

@end
